/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 30318
 * Date: 2023-05-13
 * Time: 11:40
 */
public class Test {

    public static long fib(int n){
        long f1 = 1;
        long f2 = 1;
        long f3 = 1;
        for (int i = 3; i <= n ; i++) {
            f3 = f1+f2;
            f1 = f2;
            f2 = f3;
        }
        return f3;
    }

    public static void main(String[] args) {
        System.out.println(fib(1));
        System.out.println(fib(2));
        System.out.println(fib(3));
        System.out.println(fib(4));
        System.out.println(fib(5));
    }

    /**
     * 求两个整数的最大值
     * @param a
     * @param b
     * @return
     */
    public static int max(int a, int b){
        return a > b ? a : b;
    }
//    public static void max2(int a, int b) {//无返回值
//        if (a > b) {
//            System.out.println(a);
//        } else {
//            System.out.println(b);
//        }
//  }
    public static int max(int a, int b, int c) {
        int ret = max(a, b);
        return ret > c ? ret : c;
    }

    public static void main5(String[] args) {
        System.out.println(max(1, 2, 3));
    }

    public static int sum(int a, int b){
        return a+b;
    }

    public static int sum(int a, int b, int c){
        return a+b;
    }

    public static double sum(int a, double b, int c){
        return a+b;
    }

    public static double sum(double b, int c, int a){
        return a+b;
    }

    public static double sum(double a, double b){
        return a+b;
    }

    public static void main4(String[] args) {
        int a = 10;
        int b = 20;
        int ret = sum(a,b);
        System.out.println(ret);

        double d1 = 12.3;
        double d2 = 12.3;
        double ret2 = sum(d1, d2);
        System.out.println(ret2);
    }
    //方法名称必须一样
    //方法的参数不一样【数据类型 个数 顺序】
    //返回值没有要求

    public static void swap(int a, int b){
        int tmp = a;
        a = b;
        b = tmp;
    }

    public static void main3(String[] args) {
        int a = 10;
        int b = 20;
        System.out.println(a+" "+b);
        swap(a,b);
        System.out.println(a+" "+b);
    }

    public static int facSum(int n){
        int sum = 0;
        for(int i = 1; i <= n; i++){
            sum += fac(i);
            /*int ret = 1;
            for(int j = 1; j <= n; j++){
                ret *= j;
            }
            sum += ret;*/
        }
        return sum;
    }

    /**
     * 求n的阶乘
     * @param n
     * @return
     */
    public static int fac(int n){
        int ret = 1;
        for(int i = 1; i <= n; i++){
            ret *= i;
        }
        return ret;
    }

    public static void main2(String[] args) {
        int ret =facSum(5);
        System.out.println(ret);
    }

    public static void main1(String[] args) {
        int x = 1;
        int y = 2;
        //接收方法的返回值
        int ret = add(x, y);//实际参数
        System.out.println(ret);
    }

    /*public static void add(int a, int b){
        System.out.println(a+b);
    }*/
    public static int add(int a, int b){
        //System.out.println(a+b);
        return a+b;
    }
}
